package org.example;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;


class Node implements Comparable<Node> {

    int x;
    int y;
    int G;
    int H;
    int cost;

    Node(int x, int y, int G, int H, int cost) {
        this.x = x;
        this.y = y;
        this.G = G;
        this.H = H;
        this.cost = cost;
    }

    @Override
    public int compareTo(Node o) {
        return Integer.compare(this.G + this.H, o.G + o.H);
    }
}

public class Main {

    private static final int[][] DIRS = {{2, 1}, {1, 2}, {-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}};

    private static int calcH(int a1, int a2, int b1, int b2) {
        return (a1 - b1) * (a1 - b1) + (a2 - b2) * (a2 - b2);
    }

    private static int aStar(int a1, int a2, int b1, int b2) {

        PriorityQueue<Node> queue = new PriorityQueue<>();
        Node st = new Node(a1, a2, 0, calcH(a1, a2, b1, b2), 0);
        queue.offer(st);
        while (!queue.isEmpty()) {
            Node cur = queue.poll();
            if (cur.x == b1 && cur.y == b2) {
                return cur.cost;
            }
            for (int[] dir : DIRS) {
                int offsetX = dir[0];
                int offsetY = dir[1];
                int nextX = cur.x + offsetX;
                int nextY = cur.y + offsetY;
                if (nextX < 1 || nextX > 1000 || nextY < 1 || nextY > 1000) {
                    continue;
                }
                int G = cur.G + 5;
                int H = calcH(nextX, nextY, b1, b2);
                int cost = cur.cost + 1;
                queue.offer(new Node(nextX, nextY, G, H, cost));
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int a1 = sc.nextInt();
            int a2 = sc.nextInt();
            int b1 = sc.nextInt();
            int b2 = sc.nextInt();
            int cost = aStar(a1, a2, b1, b2);
            System.out.println(cost);
        }
    }
}